Array.prototype.indexOf = function(p_var) 
{ 
	for (var i=0; i<this.length; i++) { 
		if (this[i] == p_var) {
			return(i);
		} 
	}
	return(-1);
}
 
Array.prototype.remove = function(o) { 
	var i = this.indexOf(o); 
	if (i>-1) 
		this.splice(i,1); 
	return (i>-1) 
} 

function redirectTo(url)
{
	window.location = url;
}

function isNull(val)
{
	return(val==null || typeof(val)=="undefined");
}

function isBlank(val){
	if(isNull(val))
		return true;
	val += "";
	for(var i=0;i<val.length;i++) {
		switch(val.charAt(i))
		{
			case " ":
			case "\t":
			case "\n":
			case "\r":
				break;
			default:
				return false;
		}
	}
	return true;
}

function ltrim(str)
{
	if (isNull(str))
		return "";
	str += "";
	for (var i=0; str.length; i++)
	{
		var ch = str.charAt(i);
		if(ch==" " || ch=="\n" || ch=="\t")
			continue;
		break;
	}
	return str.substring(i,str.length);
}

function rtrim(str)
{
	if (isNull(str))
		return "";
	str+="";
	for (var i=str.length-1; i>=0; i--)
	{
		var ch = str.charAt(i);
		if(ch==" " || ch=="\n" || ch=="\t")
			continue;
		break;
	}
	return str.substring(0,i+1);
}

function trim(str)
{
	return ltrim(rtrim(str));
}

function isValidEmail(email)
{
	if (isBlank(email))
		return false;
	var reg =/^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,4}$/;
	return reg.test(email);
}


function GetAJAXObject()
{  
	try
    {    // Firefox, Opera 8.0+, Safari    
    	xmlHttp=new XMLHttpRequest();    
    }
  	catch (e)
    {   // Internet Explorer    
    	try
      	{
      		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
      	}
    	catch (e)
      	{      
      		try
        	{
        		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
        	}
			catch (e)
			{
				return false;
			}
		}
	}
	return xmlHttp;
}

function CallAjaxFunction(url)
{
	var xmlHttp = GetAJAXObject();
	xmlHttp.open("GET", url, false);
	xmlHttp.setRequestHeader( "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
	xmlHttp.send(null);
	var ret = xmlHttp.responseText+"";
	xmlHttp = null;
	alert(ret);
	var res = eval("("+ret+")");

	return res;
}